package com.xy.scheduled.timing;


import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.util.Date;

@Component
public class TimingDemo {
    private Date date;
    @Scheduled(cron ="0/2 * * * * ?")
    public void timingMethod(){
        date = new Date();
        System.out.println("timingMethod定时器被触发"+ DateFormat.getDateTimeInstance().format(date));
    }
}
